package com.itheima;

public class Test8 {
    public static void main(String[] args) {
        String s1 = "you are beatfull";
        //全部转换成大写
        String s2 = s1.toUpperCase();
        System.out.println(s2);
        //全部转换成小写
        String s3 = s2.toLowerCase();
        System.out.println(s3);
        //将s1的首尾空格去掉
        String s4 = s1.trim();
        System.out.println(s4);
        //判断s1中是否包含"are";
        boolean flag1 = s1.contains("are");
        System.out.println(flag1);
        //判断句子的起始是否为某个元素
        //例如"王"
        String s5 = "王侯将相,宁有种乎";
        boolean flag2 = s5.startsWith("王");
        System.out.println(flag2);
        //判断句子的末尾是否以某个元素结尾
        //例如"乎"
        boolean flag3 = s5.startsWith("乎");
        System.out.println(flag3);
        //统计姓"吴"的人数为几个
        String[] names = {"陈胜","吴广","吴刚","吴又"};
        String str = "";
        for (int i = 0; i < names.length; i++) {
            str += names[i];
        }
        char[] chars = str.toCharArray();
        for (int i = 0; i < names.length; i++) {
            System.out.println(chars[i]);

        }



        //获取单个元素在整个字符串中的位置
        String s6 = "上海自来水来自海上";
        int index = s6.indexOf("海");
        System.out.println(index);

    }
}
